﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.world.vos.actors.machines {
    import flash.events.*;
    import net.wooga.pets.interfaces.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;

    public class KindergartenMachineVO extends AbstractMachineVO {

        private var _babys:Array;
        private var _positions:Array;

        private static const EMPTY:String = "empty";

        public function KindergartenMachineVO(_arg1:Object, _arg2:IEventDispatcher){
            this._babys = [];
            this._positions = [EMPTY, EMPTY, EMPTY];
            super(_arg1, _arg2);
        }
        override public function handleBaby(_arg1:IBaby, _arg2:Boolean):void{
            dispatch(updateEvent);
            this._babys.push(_arg1);
            this._positions[(this.getFreePos - 1)] = _arg1;
            _arg1.setInitialState();
        }
        override public function set state(_arg1:String):void{
            super.state = _arg1;
        }
        override public function get isFree():Boolean{
            return ((this.noOfBabys <= GameConstants.MAX_BABY_NUM));
        }
        public function get noOfBabys():int{
            return ((this._babys.length + 1));
        }
        public function get getFreePos():int{
            var _local1:int;
            while (_local1 < this._positions.length) {
                if (this._positions[_local1] == EMPTY){
                    return ((_local1 + 1));
                };
                _local1++;
            };
            return (0);
        }
        public function getPosOfBaby(_arg1:IBaby):int{
            var _local2:int;
            while (_local2 < this._positions.length) {
                if (this._positions[_local2] == _arg1){
                    return ((_local2 + 1));
                };
                _local2++;
            };
            return (0);
        }
        public function removeBaby(_arg1:IBaby):void{
            Arrays.removeFromArray(this._babys, _arg1);
            this._positions[(this.getPosOfBaby(_arg1) - 1)] = EMPTY;
        }

    }
}//package net.wooga.pets.models.world.vos.actors.machines 
